<!-- BEGIN PAGE HEADER-->
<?php $this->load->view('partials/breadcrumb.tpl',  Array('_NO_IOSS_NEW'=>'1'))?>
<!-- END PAGE HEADER-->
<!-- BEGIN PAGE CONTENT-->
<style>
    th,td{
        text-align: center;
    }
</style>
<script type="text/javascript">
function defConfirm(){
	if(!confirm("确定进行此操作吗？")){
		return false;
	}
	return true;
}
$(document).ready(function(){
	$("#reset").click(function(){
		$("select").val('');
		$("input[type='text']").val('');
	});
});
</script>
<div class="row">
	<div class="col-xs-12">
		<!-- Begin: life time stats -->
		<div class="portlet">
			<?= form_open('', Array('class' => 'form-inline', 'role' => 'form')) ?>
			<?= search_form_dropdown('user_type', array('' => '用户状态...')+MUser::getUserType(), filterValue('user_type'), '用户状态', 'class="form-control input-small"'); ?>
			<?= search_form_dropdown('wx_bind', array('' => '绑定微信...')+MUser::getWxBind(), filterValue('wx_bind'), '绑定微信', 'class="form-control input-small"'); ?>
			<?= search_form_dropdown('auth_status', array('' => '认证状态...')+MUser::getAuthState(), filterValue('auth_status'), '认证状态', 'class="form-control input-small"'); ?>
			<?= search_form_input('open_id', filterValue('open_id'), '微信openID', 'class="form-control input-small"'); ?>
			<?= search_form_input('mobile', filterValue('mobile'), '手机号', 'class="form-control input-small"'); ?>
			<?= search_form_input('nick_name', filterValue('nick_name'), '昵称', 'class="form-control input-small"'); ?>
			<?= search_form_dropdown('sex', array('' => '性别...')+MUser::getSex(), filterValue('sex'), '性别', 'class="form-control input-small"'); ?>
			<div style="clear:both;height: 15px;"></div>
			<?= search_form_input('user_number_perpage', filterValue('user_number_perpage'), '每页显示条数', 'class="form-control input-small"'); ?>
			<div class="input-group input-large date-picker input-daterange" data-date="" data-date-format="yyyy-mm-dd">
				<input type="text" class="form-control" name="user_create_time_begin"
					   value="<?= filterValue('user_create_time_begin') ?>" placeholder="入驻起始时间" autoComplete="off">
				<span class="input-group-addon">to </span>
				<input type="text" class="form-control" name="user_create_time_end"
					   value="<?= filterValue('user_create_time_end') ?>" placeholder="入驻结束时间" autoComplete="off">
			</div>
			<button type="button" class="btn default" id="reset">重置条件</button>
			<button type="submit" class="btn green about_search">搜索 <i class="fa fa-search"></i></button>
			<?= form_close() ?>
			<div class="portlet-body">
				<div class="row">
					<div class="col-xs-12">
						<div class="table-scrollable">
							<table class="table table-hover table-bordered table-striped">
								<thead>
								<tr>
									<th>ID</th>
									<th>头像</th>
									<th>昵称</th>
									<th>性别</th>
									<th>地址</th>
									<th>手机号</th>
									<th>openID</th>
									<th>绑定微信</th>
									<th>认证状态</th>
									<th>保证金</th>
                                    <th>账户状态</th>
									<th>创建时间</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								<?php foreach ($list as $v) { ?>
								<tr>
									<td><?= $v->id ?></td>
									<td>
                                        <img class="img-rounded" style="width: auto;height: 60px;" src="<?= $v->avatar ?>" />
                                    </td>
									<td><?= $v->nick_name ?></td>
									<td><?= MUser::getSex($v->sex) ?></td>
									<td><?=$v->province?> <?=$v->city?></td>
									<td><?=$v->mobile?></td>
									<td><?=$v->open_id?></td>
									<td><?= MUser::getWxBind($v->wx_bind) ?></td>
									<td><?= MUser::getAuthState($v->auth_status) ?></td>
									<td><?= MUser::getPromiseState($v->promise_status) ?></td>
									<td><?= $v->user_type?'<label class="label label-success">正常</label>':'<label class="label label-danger">已拉黑</label>' ?></td>
									<td><?= date('Y-m-d H:i:s', $v->create_time) ?></td>
									<td>
										<div class="btn-group btn-group-solid">
                                            <?php if ($v->user_type): ?>
											<a href="JavaScript:;" data-id="<?= $v->id ?>" class="bad-user btn btn-sm btn-danger"><i class="fa fa-slideshare"></i> 拉黑</a>
                                            <?php else: ?>
                                            <a href="JavaScript:;" data-id="<?= $v->id ?>" class="good-user btn btn-sm btn-info"><i class="fa fa-slideshare"></i> 取消拉黑</a>
                                            <?php endif; ?>
										</div>
									</td>
								</tr>
								<?php } ?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12 text-right">
						<?= $pagination ?>
					</div>
				</div>
			</div>
		</div>
		<!-- End: life time stats -->
	</div>
</div>

<!-- END PAGE CONTENT-->
<script type="text/javascript">
	$(document).ready(function () {
		$('.img-rounded').zoomify();
	});
    $(".good-user").click(function () {
        var uid = this.dataset.id;
        if (defConfirm()){
            $.ajax({
                url: "<?= site_url('user/user/change_user') ?>",
                method: "POST",
                data: {'id': uid, 'user_type': 1},
                dataType: "JSON",
                success: function (data) {
                    if (data.status){
                        toastr.success(data.msg,'成功');
                        setTimeout(function () {
                            location.reload()
                        },1000)
                    }else {
                        toastr.error(data.msg,'失败');
                    }
                }
            })
        }
    })
    $(".bad-user").click(function () {
        var uid = this.dataset.id;
        if (defConfirm()){
            $.ajax({
                url: "<?= site_url('user/user/change_user') ?>",
                method: "POST",
                data: {'id': uid, 'user_type': 0},
                dataType: "JSON",
                success: function (data) {
                    if (data.status){
                        toastr.success(data.msg,'成功');
                        setTimeout(function () {
                            location.reload()
                        },1000)
                    }else {
                        toastr.error(data.msg,'失败');
                    }
                }
            })
        }
    })
</script>
